import EffectType from "./EffectType";
import IActiveEffect from "./IActiveSkillEffect";
import HurtEffect from "./impl/HurtEffect";
import IPassiveSkillEffect from "./IPassiveSkillEffect";

/**
 * 技能效果管理器
 */
export default class SkillEffectMgr {
    private static _instance: SkillEffectMgr;

    public static get Ins(): SkillEffectMgr {
        if (!SkillEffectMgr._instance) {
            SkillEffectMgr._instance = new SkillEffectMgr();
            SkillEffectMgr._instance.init();
        }
        return SkillEffectMgr._instance;
    }
    // 技能效果脚本
    activeEffectScripts:Map<number,IActiveEffect> = new Map();
    // 被动技能效果脚本
    passiveEffectScripts:Map<number,IPassiveSkillEffect> = new Map();
    public init() {
        //注册技能效果脚本
        this.addEffectScript(EffectType.Hurt,new HurtEffect())
    }

    addEffectScript(effectId:number,effect:IActiveEffect|IPassiveSkillEffect) {
        if("activeEffect" in effect){
            this.activeEffectScripts.set(effectId,effect as IActiveEffect);
        }
        if("passiveEffect" in effect){
            this.passiveEffectScripts.set(effectId,effect as IPassiveSkillEffect);
        }
    }
}